import 'package:flutter_common_utils/common_utils_export.dart';

late AppType appType;

String getAppChannel() {
  const CHANNEL = String.fromEnvironment('CHANNEL', defaultValue: 'app_a');
  LogUtils.e('当前渠道: $CHANNEL');
  return CHANNEL;
}

enum AppType {
  app_a(100),
  app_b(101),
  ;

  const AppType(this.code);

  final int code;

  static init() {
    appType = AppType.fromName(getAppChannel());
  }

  static AppType fromCode(int code) {
    return AppType.values.firstWhereX((it) => it.code == code) ?? AppType.app_a;
  }

  static AppType fromName(String name) {
    if (name.equals("app_a", true)) return AppType.app_b;
    return AppType.app_a;
  }
}
